<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css" /> -->
  </head>

  <body>
    <div id="app">
      <h2>Hello {{count}}</h2>

      <button @click="count++">count++</button>

      <h2>x+y={{x+y}}</h2>
      <button @click="x++">x++</button>
      <button @click="y++">y++</button>
    </div>
    <script type="module">
      import {
        createApp,
        ref,
        reactive,
        computed,
        watch,
      } from "./vue.esm-browser.js";
      const app = createApp({
        setup() {
          const count = ref(0);
          const x = ref(10);
          const y = ref(20);
          // watch(count, (newValue, oldValue) => {
          //   console.log(newValue, oldValue);
          // });
          // watch(
          //   () => x.value + y.value,
          //   (newSum, oldSum) => {
          //     console.log(newSum, oldSum);
          //   }
          // );
          /*  watch(
            [count, x, y, () => x.value + y.value],
            (newValue, oldValue) => {
              console.log(newValue, oldValue);
            }
          ); */
          watch(
            [count, x, y, () => x.value + y.value],
            ([count, x, y, sum], oldValue) => {
              console.log(count, x, y, sum);
              console.log(oldValue);
            }
          );
          return {
            count,
            x,
            y,
          };
        },
      });

      app.mount("#app"); //挂载
    </script>
  </body>
</html>
